package net.wantongtech.xa.uploadbasicinfo.config;

import lombok.Data;
import org.csource.fastdfs.ClientCommon;
import org.csource.vo.GolobalInfo;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * FastDFS配置
 *
 * @author MaShibo
 * 日期 :  2020/1/31
 */
@Data
@Component
@ConfigurationProperties(prefix = "fdfs")
public class FastDFSConfig {

    private int connectTimeOut = 3;

    private int netWorkTimeOut = 10;

    private String charset = "UTF-8";

    private String trackerServer;

    @PostConstruct
    public void init() {
        GolobalInfo golobalInfo = new GolobalInfo();
        golobalInfo.setCharset(this.charset);
        golobalInfo.setConnectTimeout(this.connectTimeOut);
        golobalInfo.setNetworkTimeout(this.netWorkTimeOut);
        golobalInfo.setTrackerServers(new String[]{this.trackerServer});
        ClientCommon.init(golobalInfo);
    }
}
